<?php 
class help_home
{ 
	function home_help_list() 
	{ 
		global $mysql_conn,$v_file;
		$list_page = $_GET['list_page'];
		$list_num = $_GET['list_num'];
		$sousuokey = $_GET['sousuokey'];
		$help_type = $_GET['help_type'];
		if (empty($list_page)) $list_page = 1;
		if (empty($list_num)) $list_num = 10;
		if ($list_page < 5) {$list_page0 = 1;} else {$list_page0 = $list_page-4;}
		if ($list_page < 5) {$list_page1 = 1;} else {$list_page1 = $list_page-3;}
		if ($list_page < 5) {$list_page2 = 2;} else {$list_page2 = $list_page-2;}
		if ($list_page < 5) {$list_page3 = 3;} else {$list_page3 = $list_page-1;}
		if ($list_page < 5) {$list_page4 = 4;} else {$list_page4 = $list_page;}
		if ($list_page < 5) {$list_page5 = 5;} else {$list_page5 = $list_page+1;}
		if ($list_page < 5) {$list_page6 = 6;} else {$list_page6 = $list_page+2;}
		if ($list_page < 5) {$list_page7 = 7;} else {$list_page7 = $list_page+3;}
		if ($list_page < 5) {$list_page8 = 8;} else {$list_page8 = $list_page+4;}
		$page_btn .= "<button type='button' class='btn btn-white' onClick='list_page_go(".$list_page0.")'><i class='fa fa-chevron-left'></i></button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page1."' onClick='list_page_go(".$list_page1.")'>".$list_page1."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page2."' onClick='list_page_go(".$list_page2.")'>".$list_page2."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page3."' onClick='list_page_go(".$list_page3.")'>".$list_page3."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page4."' onClick='list_page_go(".$list_page4.")'>".$list_page4."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page5."' onClick='list_page_go(".$list_page5.")'>".$list_page5."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page6."' onClick='list_page_go(".$list_page6.")'>".$list_page6."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page7."' onClick='list_page_go(".$list_page7.")'>".$list_page7."</button>";
		$page_btn .= "<button type='button' class='btn btn-white' onClick='list_page_go(".$list_page8.")'><i class='fa fa-chevron-right'></i></button>";
		$list_limit = ($list_page-1)*$list_num.",".$list_num;
		$sql = "SELECT * from `help` limit ".$list_limit;
		if (!empty($sousuokey)) {
			$sql = "SELECT * from `help` WHERE `help_title` = '".$sousuokey."'";
		} 
		if (!empty($help_type)) {
			$sql = "SELECT * from `help` WHERE `help_type` = '".$help_type."' limit ".$list_limit;
		}
		$result = mysql_query($sql,$mysql_conn);
		while(@$row=mysql_fetch_array($result)) {
			$help_id = $row['help_id'];
			$help_type = $row['help_type'];
			$help_title = $row['help_title'];
			$help_body = $row['help_body'];
			$sql_type = "SELECT * from `help_type` WHERE `type_id` = '".$help_type."'";
			$result_type = mysql_query($sql_type,$mysql_conn);
			@$row_type=mysql_fetch_array($result_type);
			$help_type_name = $row_type['type_name'];
			$helplist .= "<tr>";
			$helplist .= "<td>".$help_id."</td>";
			$helplist .= "<td>".$help_type_name."</td>";
			$helplist .= "<td>".$help_title."</td>";
			$helplist .= "<td>".$help_body."</td>";
			$helplist .= "</tr>";
		}
		$sql = "SELECT * from `help_type` ";
		$result = mysql_query($sql,$mysql_conn);
		while(@$row=mysql_fetch_array($result)) {
			$type_id = $row['type_id'];
			$type_name = $row['type_name'];
			$typelist .= "<a href='#' class='btn btn-primary btn-xs' onclick='help_type(".$type_id.");'>".$type_name."</a>";
		}
		require($v_file);
	}
} 
/* End of file democontroller.php */ 